//
//  ByUserMyRealNameFirstVC.m
//  jinpuyiyuan_ios
//
//  Created by pro on 2017/12/14.
//  Copyright © 2017年 mc. All rights reserved.
//

#import "ByUserMyRealNameFirstVC.h"

// vc
#import "ByUserMyRealNameSecondVC.h"

// cell
#import "ByCellUserMyRealName.h"
@interface ByUserMyRealNameFirstVC ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, copy) NSArray *titles;
@end

@implementation ByUserMyRealNameFirstVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"实名";
    [self addLeftBackBarButtonItem];
    [self createViews];
}

#pragma mark - getter
- (NSArray *)titles{
    if (!_titles) {
        _titles = @[@"身份证号：",@"姓名：",@"性别：",@"名族：",@"生日：",@"地址：",@"签证机关：",@"有效日期："];
    }
    return _titles;
}

#pragma mark - create views
- (void)createViews{
    self.tableView = [[UITableView alloc] init];
    [self.view addSubview:self.tableView];
    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(0));
        make.right.equalTo(@(0));
        if (@available(iOS 11.0,*)) {
            make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom).offset(-40);
            make.top.equalTo(self.view.mas_safeAreaLayoutGuideTop);
        }else{
            make.bottom.equalTo(self.view.mas_bottom);
            make.top.equalTo(self.view.mas_top);
        }
    }];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    UIButton *nextButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.view addSubview:nextButton];
    [nextButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(0));
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH, 40));
        if (@available(iOS 11.0,*)) {
            make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom);
        }else{
            make.bottom.equalTo(self.view.mas_bottom);
        }
    }];
    [nextButton setTitle:@"下一步" forState:UIControlStateNormal];
    [nextButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [nextButton setBackgroundColor:BY_THEME_COLOR];
    nextButton.titleLabel.font = FONT(16);
    [nextButton addTarget:self action:@selector(nextAction) forControlEvents:UIControlEventTouchUpInside];
}

#pragma mark - UITableViewDelegate,UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return self.titles.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    ByCellUserMyRealName *cell = [ByCellUserMyRealName cellWithTableView:tableView];
    cell.title = self.titles[indexPath.section];
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 40;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    if (section == 0) {
        return 30;
    }
    return 10;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.0001;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    return [UIView new];
}

#pragma mark - 下一步
- (void)nextAction{
    ByUserMyRealNameSecondVC *vc = [[ByUserMyRealNameSecondVC alloc] init];
    [self by_normalPush:vc hasNavi:YES];
}
@end
